<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script>
        function fn(a, b) {
            if (a > b) {
                var s = a;
                a = b;
                b = s;
            }
            for (; a <= b; a++) {
                var d = 0;
                for (var i = 1; i <= a; i++) {
                    if (a % i == 0) {

                        d++;
                    }
                }
                if (d == 2) {
                    document.write(a + "这个数是质数")
                }
            }
        }
        var a = prompt("求a~b之间的质数,请输入a","1")
        var b = prompt("求a~b之间的质数,请输入b","10")
        fn(a, b);
        // document.write(a)
        // document.write(a+"这个数是质数")
    </script>
</head>

<body>

</body>

</html>